<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        .el-page-header__content {
            font-size: 18px;
            color: white;
        }
    </style>
</head>
<body>
<div id="app">
<el-page-header @back="goBack" content="入住登记修改"   style="background-color:#E6A23C;color: white;  line-height: 60px">
</el-page-header>
    <el-card style="width: 600px;height: 700px;margin: 0 auto">
        <el-form label-width="80px">
            <el-form-item label="老人姓名"  style="width:300px">
                <el-select v-model="value"  @change="select(value)">
                    <el-option
                            v-for="item in options"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="性别:">
                <el-input v-model="olderArr.gender" type="text" readOnly  ="true"></el-input>
            </el-form-item>
            <el-form-item label="联系方式:">
                <el-input v-model="olderArr.phoneNum" type="text"  readOnly  ="true"></el-input>
            </el-form-item>
            <el-form-item label="入住时间:"  style="width:300px">
                <el-date-picker
                        v-model="olderArr.checkDate"
                        type="date"
                >
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="success" @click="update()">入住登记修改</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                options: [],
                olderArr:{},
                value: "",
            }
        },
        methods: {
            goBack() {
                //返回上一页面
                history.back();
            },update()
            {
              v.olderArr.checkId = location.search.split("=")[1];
               axios.post("/check/updateByid",v.olderArr).then(function (response)
               {
                   v.$message("修改成功");
                 location.href = "/admin.html";
               })
            },select(value)
            {
                let d =  v.olderArr.checkDate;
                axios.get("/check/selectOlderByid?id="+value).then(function (response) {
                    v.olderArr = response.data;
                    v.olderArr.checkDate = d;
                })
            }
        },
        created:function (){
            axios.get("/check/selectByid"+location.search).then(function (response)
            {
                v.olderArr = response.data;
                v.value = response.data.name;
            })
          axios.get("/check/selectOlderAll").then(function (response)
          {
             v.options = response.data;
          })
        }
    })
</script>
</body>
</html>